package com.ronan.imweb.controller;

import com.ronan.common.pojo.RimUmsInfo;
import com.ronan.common.response.Result;
import com.ronan.imweb.req.LoginUmsReq;
import com.ronan.imweb.req.RegisterUmsReq;
import com.ronan.imweb.service.UmsInfoService;
import com.ronan.imweb.vo.LoginUmsVo;
import com.ronan.imweb.vo.RegisterUmsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

/**
 * FileName    : com.ronan.imweb.controller
 * Description :
 *
 * @author : ronan
 * @version : 1.0
 * Create Date : 2021/3/16 14:15
 **/
@RestController
@RequestMapping(value = "/im/web/ums")
public class UmsInfoController {

    @Autowired
    private UmsInfoService umsInfoService;

    /**
     * 注册
     *
     * @param req 请求参数
     * @return {@link Result<RegisterUmsVo>}
     */
    @PostMapping(value = "/register")
    public Result<RegisterUmsVo> register(@RequestBody @Validated RegisterUmsReq req) {
        return umsInfoService.register(req);
    }

    /**
     * 登录
     *
     * @param req 请求参数
     * @return {@link Result<LoginUmsVo>}
     */
    @PostMapping(value = "/login")
    public Result<LoginUmsVo> login(@RequestBody @Validated LoginUmsReq req) {
        return umsInfoService.login(req);
    }

    /**
     * 离线
     *
     * @param ums 口头语
     * @return {@link Result}
     */
    @PostMapping(value = "/offline")
    public void offline(@RequestBody @Validated RimUmsInfo ums) {
        umsInfoService.offline(ums);
    }

    /**
     * 在线用户
     *
     * @return {@link Result<Set<RimUmsInfo>>}
     */
    @PostMapping(value = "/onlineUms")
    public Result<Set<RimUmsInfo>> onlineUms() {
        return umsInfoService.onlineUms();
    }
}
